#include <iostream>
#include <stack>
#include <vector>
#include <map>
#include <stack>

using namespace std;

struct TreeNode {
    int val;
    struct TreeNode *left;
    struct TreeNode *right;
    TreeNode(int x) :
            val(x), left(NULL), right(NULL) {
    }
};
class Solution {
public:
    vector<vector<int> > Print(TreeNode* pRoot) {
        vector<vector<int> > ans;
        stack<TreeNode*> s1,s2;
        if(pRoot==nullptr) return ans;
        s1.push(pRoot);
        while(!s1.empty() || !s2.empty()){
            if(!s1.empty()){
                vector<int> t;
                while(!s1.empty()){
                    TreeNode *tn=s1.top();s1.pop();
                    t.push_back(tn->val);
                    if(tn->left) s2.push(tn->left);
                    if(tn->right) s2.push(tn->right);
                }
                ans.push_back(t);
            }
            if(!s2.empty()){
                vector<int> t;
                while(!s2.empty()){
                    TreeNode *tn=s2.top();s2.pop();
                    t.push_back(tn->val);
                    if(tn->right) s1.push(tn->right);
                    if(tn->left) s1.push(tn->left);
                   
                }
                ans.push_back(t);
            }
        }
        return ans;
    }
    
};
int main(){




    return 0;
}